#!/usr/bin/env python
#
#   example of PyMetaInfo process usage
#

import sys
from pprint import pprint
from pyflowctrl import core4 as core 
from pyflowctrl.core4.processes.pymetainfo2 import PyMetaInfo

if len(sys.argv) <> 2:
    print "Please specify module"
    sys.exit()
    
network =  {
    'processes': {
        'meta_extract': PyMetaInfo(),
    },
    'links': {},
}

flow = core.ProcessFlow()
flow.upload(network)
flow.pmap['meta_extract'].io['input'].put(core.Packet(module=sys.argv[1]))
flow.run()
try:
    pprint(flow.pmap['meta_extract'].io['output'].get().dump())
except core.EmptyStream:
    print 'No metadata for %s' % sys.argv[1]

